package com.bao.work;

import java.io.*;
import java.util.TreeSet;

/**
 * @author baoye
 * @date 2024-08-06/20:01
 */
public class Work07 {
    public static void main(String[] args) throws IOException {
        InputStreamReader in = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(in);
        TreeSet<Student> students = new TreeSet<>();
        while(true){
            System.out.println("请输入学号");
            String sid = br.readLine();
            if ("exit".equals(sid)) {
                System.out.println("退出");
                break;
            }
            System.out.println("请输入姓名");
            String name = br.readLine();
            if ("exit".equals(name)) {
                System.out.println("退出");
                break;
            }
            System.out.println("请输入年龄");
            String age = br.readLine();
            if ("exit".equals(age)) {
                System.out.println("退出");
                break;
            }
            Student s1=new Student(sid,name, Integer.parseInt(age));
            students.add(s1);
        }
        br.close();
        in.close();
        ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream("day10/src/com/bao/work/student.txt"));
        for (Student student : students) {
            oos.writeObject(student);
            oos.writeChar('\n');
            oos.flush();
        }
        oos.close();


    }
}
